Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make strings in theme.json translatable #66675

Merged

Conversation

d-alleyne
Copy link
Contributor

@d-alleyne d-alleyne commented Nov 1, 2024

What?

Aspect Ratios and Shadow Presets are untranslated. The strings aren't in GlotPress.

Why?

This PR resolves the missing Aspect Ratios in #66027.

How?

By adding a symlink to theme.json in the project's root directory, strings will be extracted

Testing Instructions

  1. Download the plugin locally.
  2. Make POT with wp i18n make-pot ..
  3. Inspect the generated gutenberg.pot file to confirm that the Aspect Ratio strings from theme.json are not being extracted.

N.B the shadow.presets strings are not extracted.

Testing Instructions for Keyboard

Screenshots or screencast

Copy link

github-actions bot commented Nov 1, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: d-alleyne <[email protected]>
Co-authored-by: swissspidy <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: oandregal <[email protected]>
Co-authored-by: spacedmonkey <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@skorasaurus skorasaurus added the Internationalization (i18n) Issues or PRs related to internationalization efforts label Nov 12, 2024
@swissspidy swissspidy added the [Type] Enhancement A suggestion for improvement. label Dec 16, 2024
theme.json Outdated
@@ -0,0 +1 @@
lib/theme.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd actually move the file instead of adding a symlink

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lib/theme.json location was working before; why change it now?

cc @oandregal

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is explained in #66027

WP-CLI assumes that theme.json only exists in a theme, and in themes it's required to be in the root. It does not look for any other subfolders and I don't wanna change that in WP-CLI.

The Gutenberg plugin is an exception because it holds the "source of truth" for theme.json and does so in the lib folder.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to catch up a bit on this, but last I checked (3 years ago) it was working fine (it extracted strings from core, Gutenberg, and themes).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also searched for specific strings that are only defined in theme.json. Example: "Dark grayscale" for duotone. Same result, they are not present in translate:

Gutenberg WordPress
Screenshot 2024-12-18 at 17 43 23 Screenshot 2024-12-18 at 17 43 02

This comment was marked as outdated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More context: for testing, avoid using color gradients, palette, or font sizes. Some of these are also defined in the client (see) so it can give you false positives.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, if I do the same search for WordPress core and Gutenberg, there are no strings coming from theme.json

With that current logic in WP-CLI that would be expected. As I said, it only looks for a specific location at the moment.

That change was made with the assumption that theme.json is supposed to live only in themes and in the root folder of theme. This helped avoid an issue where, when extracting strings in core, theme.json strings from all the default themes were erroneously included (because they live in wp-content.

I suppose we didn't realize at the time that wp-includes/theme.json also exists... 🤔

it sounds we haven't been extracting strings from the theme.json provided by WordPress (or Gutenberg) since 2 years ago?

Yes, you're right. Hmm we need to make some changes to WP-CLI then and to Meta (sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/inc/cli/class-make-core-pot.php)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing the loop here: we're continuing the conversation at wp-cli/i18n-command#423

@swissspidy swissspidy requested a review from Mamaduka December 16, 2024 15:41
"shadow": {
"presets": [
{
"name": "Shadow presets name"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"name": "Shadow presets name"
"name": "Shadow preset name"

Let's match the naming pattern

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we perhaps use Shadow name instead? That's inline with what other presets do:

  • font sizes: "font size name"
  • colors: "color name"
  • aspect ratios: "aspect ratio name"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: these changes need to be backported to wordpress-develop so that the wp-cli uses them (see). Until then, these strings won't be picked up from anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oandregal , I created a diff for wordpress-develop, but it instructs that the description should have a trac number. Do we have one, or do I create one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use https://meta.trac.wordpress.org/ticket/7866 I've left a comment linking to this PR and the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oandregal I had created https://core.trac.wordpress.org/ticket/62728. I hope it isn't an issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's good as well 👍

@oandregal
Copy link
Member

@d-alleyne I think limiting the changes in this PR only to the theme-i18n.json and then preparing a similar PR for wordpress-develop would be best here. This will fast-track those changes.

The other conversation (why WordPress and Gutenberg theme.json files aren't picked up for translation) is a bit tricky and may need more investigation.

@oandregal
Copy link
Member

oandregal commented Dec 20, 2024

@d-alleyne are you able to prepare the corresponding PR to https://github.com/WordPress/wordpress-develop/?

You'd also need to push to this PR a new markdown file within backport-changelog/6.8 folder (see). That's the only blocker to land this PR and unblock the "verify core backport changelog" CI job.

@oandregal oandregal merged commit b73c95d into WordPress:trunk Dec 23, 2024
63 of 64 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.0 milestone Dec 23, 2024
@oandregal
Copy link
Member

While reviewing the core backport PR I realized there are some other things that need fixing, so I've prepared the PR at #68243

@oandregal oandregal added [Type] Bug An existing feature does not function as intended and removed [Type] Enhancement A suggestion for improvement. labels Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internationalization (i18n) Issues or PRs related to internationalization efforts [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants